#include <graphicsconveyor.h>
#include <corelib\kernel\qmath.h>
#include <Globals.h>
#include <gui\painting\qbrush.h>



namespace PackSim
{

	GraphicsConveyor::GraphicsConveyor(QGraphicsRectItem *parent)
		: QGraphicsRectItem(parent)
	{
		mDirection = QVector2D(1,0);
		setColor(QColor(Qt::gray));

	}

	GraphicsConveyor::GraphicsConveyor( GraphicsConveyor& aGraphicsConeyor )
		//: QGraphicsRectItem(aGraphicsConeyor)
	{
		mDirection = aGraphicsConeyor.getDirection();
		setColor(aGraphicsConeyor.getColor());

	}

	GraphicsConveyor::GraphicsConveyor()
	:QGraphicsRectItem(0,0)
	{
		mDirection = QVector2D(1,0);
	}

	GraphicsConveyor::~GraphicsConveyor()
	{

	}

	void GraphicsConveyor::setPos( qreal x, qreal y )
	{
		QGraphicsRectItem::setPos(x,y);
	}

	void GraphicsConveyor::setPos( const QPointF & pos )
	{
		QGraphicsRectItem::setPos(pos);
	}

	QPointF GraphicsConveyor::getPos() const
	{
		return QGraphicsRectItem::pos();
	}

	QVector2D GraphicsConveyor::getDirection() const
	{ 
		return mDirection; 
	}
	void GraphicsConveyor::setDirection(QVector2D val) 
	{ 
		mDirection = val;
		float radians = qAtan2 (val.x(),val.y());
		QGraphicsRectItem::setRotation(globalUtils::radiansToDegree(radians));
	}

	void GraphicsConveyor::setRotation( double angle )
	{
		QGraphicsRectItem::setRotation(angle);
	}

	double GraphicsConveyor::getRotation() const 
	{
		return QGraphicsRectItem::rotation();
	}

	void GraphicsConveyor::setRect( const QRectF & rectangle )
	{
		QGraphicsRectItem::setRect(rectangle);
	}

	void GraphicsConveyor::setRect( double x, double y, double width, double height )
	{
		QGraphicsRectItem::setRect(x,y,width,height);
	}

	QRectF GraphicsConveyor::getRect() const
	{
		return QGraphicsRectItem::rect();
	}

	void GraphicsConveyor::setColor(QColor& color)
	{
		mColor = color;
		QBrush brush(color);
		setBrush(brush);
	}


	QColor GraphicsConveyor::getColor() const
	{
		return mColor;
	}

	
	



}
